
use "$clean/clean_all.dta" ,clear

		   
loc experiments "posterior_comp canvassing_yes days canvass_any_main_unres  days_unres_main doors_unres_main_wins "
		   
sum years_member , d

gen years_member_med=years_member> r(p50)


		   
preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""


foreach choice in `experiments' {

/* Statistics */



  reg `choice' i.treatment $contr if  years_member_med==0 , vce(r)
     estadd loc thisstat8 = `e(N)': col`colnum'
    sigstar 1.treatment, prec(3)
    estadd loc thisstat4 = "`r(bstar)'": col`colnum'
    estadd loc thisstat5 = "`r(sestar)'": col`colnum'
	
	qui sum `choice'  if  treatment==0&years_member_med==0
	estadd scalar thisstat7 = r(mean): col`colnum'	
	
reg `choice' i.treatment $contr if  years_member_med==1 , vce(r)
	    estadd loc thisstat18 = `e(N)': col`colnum'
    sigstar 1.treatment, prec(3)
	estadd loc thisstat14 = "`r(bstar)'": col`colnum'
    estadd loc thisstat15 = "`r(sestar)'": col`colnum'
 
	
	qui sum `choice'  if  treatment==0&years_member_med==1
	estadd scalar thisstat17 = r(mean): col`colnum'	
	
	
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"
	}
	

	


loc rowlabels " " "  "{\bf Panel A: Below med. membership dur.}" " " "Treatment" " " " " "\hline Control mean" "Observations" "\midrule "   " " " " "{\bf Panel B: Above med. membership dur.}" " " "Treatment" " " " "  "\hline Control mean " "Observations" " "   "    

loc rowstats ""

forval i = 1/18{
    loc rowstats "`rowstats' thisstat`i'"
}



esttab * using "$tables/Table_A19.tex", replace cells(none) booktabs nonotes nonum compress alignment(c) ///
 nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels') ///
 fmt( 3 3 3 3 3 3 3 0 0 0 0 0 0 3 3 3 3 3 3 3 0 )) ///
 mtitle("Belief" "Any" "Days" "Any" "Days" "Door" ) ///
   mgroups("Posterior" "Intentions" "App Data" ,  pattern(1 1 0 1 0 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
